//个人中心订单列表
'use strict';
import React,{Component} from 'react';
import styles from '../style/styles';
import Icon from 'react-native-vector-icons';
import FIcon from 'react-native-vector-icons';
import OrderList from '../order/orderList';//订单列表
import {
    View,
    Text,
    TouchableOpacity,
    Image
} from 'react-native';
export default class userOrderList extends Component{
    // 构造
      constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            orderNum:1,
        };
      }

    orderNUm(){
        let orderNum = this.state.orderNum;
        if(orderNum>0){
            return(
                <View style={styles.order_num}>
                    <Text style={styles.order_num_txt}>{orderNum}</Text>
                </View>
            )
        }else{
            return null
        }
    }

    linkJump(link,title,orderStatus,user_id){

        //orderStatus===0:全部订单  1: 待付款 2:待发货 3:待收货 4:已完成 5:退换货
        let that = this;
        that.props.navigator.push(
            {
                component: link,
                passProps: {
                    title: title,
                    orderStatus:orderStatus,
                    user_id:user_id,
                    backHome:this.props.backHome
                }
            }
        );
    }

    render(){
        let datas=this.props.datas;
        let data=datas.data;
        let user_id=datas.user_id;
        return(
            <View>
                <TouchableOpacity style={styles.user_order_top} onPress={()=>this.linkJump(OrderList,'全部订单',0,user_id)}>
                    <View style={styles.user_order_left}>
                        <Image style={{height:26,width:26}} source={require('../imgs/mypayment.png')}/>
                        <Text style={{color:"#333",marginLeft:5, fontSize:16}}>我的订单</Text>
                    </View>
                    <FIcon name={'angle-right'} size={25} color={'#999'}/>
                </TouchableOpacity>
                <View style={styles.user_order}>
                    <TouchableOpacity style={styles.user_order_list} onPress={()=>this.linkJump(OrderList,'待付款订单','pending',user_id)}>
                        {parseFloat(data.order.pending_num)>0?
                            <View style={styles.order_num}>
                                <Text numberOfLines={1} style={styles.order_num_txt}>{data.order.pending_num}</Text>
                            </View>
                            :
                            null
                        }
                        <Image style={{height:26,width:26}} source={require('../imgs/payment1.png')}/>
                        <Text style={styles.order_list_title}>待付款</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.user_order_list} onPress={()=>this.linkJump(OrderList,'待发货订单','accepted',user_id)}>
                        {parseFloat(data.order.accepted_num)>0?
                            <View style={styles.order_num}>
                                <Text numberOfLines={1} style={styles.order_num_txt}>{data.order.accepted_num}</Text>
                            </View>
                            :
                            null
                        }
                        <Image style={{height:26,width:26}} source={require('../imgs/payment2.png')}/>
                        <Text style={styles.order_list_title}>待发货</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.user_order_list} onPress={()=>this.linkJump(OrderList,'待收货订单','shipped',user_id)}>
                        {parseFloat(data.order.shipped_num)>0?
                            <View style={styles.order_num}>
                                <Text numberOfLines={1} style={styles.order_num_txt}>{data.order.shipped_num}</Text>
                            </View>
                            :
                            null
                        }
                        <Image style={{height:26,width:26}} source={require('../imgs/payment3.png')}/>
                        <Text style={styles.order_list_title}>待收货</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.user_order_list} onPress={()=>this.linkJump(OrderList,'已完成订单','finished',user_id)}>
                        {parseFloat(data.order.order_sum)>0?
                            <View style={styles.order_num}>
                                <Text numberOfLines={1} style={styles.order_num_txt}>{data.order.order_sum}</Text>
                            </View>
                            :
                            null
                        }
                        <Image style={{height:26,width:26}} source={require('../imgs/payment4.png')}/>
                        <Text style={styles.order_list_title}>已完成</Text>
                    </TouchableOpacity>
                    <TouchableOpacity style={styles.user_order_list} onPress={()=>this.linkJump(OrderList,'返修/退换订单','refund',user_id)}>
                        {parseFloat(data.order.back_num)>0?
                            <View style={styles.order_num}>
                                <Text numberOfLines={1} style={styles.order_num_txt}>{data.order.back_num}</Text>
                            </View>
                            :
                            null
                        }
                        <Image style={{height:26,width:26}} source={require('../imgs/payment5.png')}/>
                        <Text style={styles.order_list_title}>退换货</Text>
                    </TouchableOpacity>
                </View>
            </View>
        )
    }
}